package student_system.Controller;

import student_system.Dao.scdao;
import student_system.bean.sc;
import student_system.bean.student;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


@WebServlet("/scselect")
public class sc_select extends HttpServlet {
    scdao dao=new scdao();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doPost(req, resp);
        String sno=req.getParameter("sno");
        if(sno==null){
            List<sc> list = dao.testArrayList();
            req.setAttribute("sclist", list);

            RequestDispatcher dispatcher = req.getRequestDispatcher("scall.jsp");
            dispatcher.forward(req, resp);
        }else {
            List<sc> list = dao.selectbysno(sno);
            //sc sc =dao.selectbysno(sno);
            req.setAttribute("sclists",list);
            RequestDispatcher dispatcher = req.getRequestDispatcher("sc_search.jsp");
            dispatcher.forward(req,resp);

        }


    }
}
